//
//  ViewController.m
//  ToolBarScrollView封装
//
//  Created by 涂永江 on 2017/8/28.
//  Copyright © 2017年 涂永江. All rights reserved.
//


#import "ViewController.h"
#import "HMDataModelTabBarContentView.h"
#import <Masonry/Masonry.h>

@interface ViewController ()

@property (strong, nonatomic)   HMDataModelTabBarContentView     *dataModelTabBarContentView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.dataModelTabBarContentView = [HMDataModelTabBarContentView new];
    
    
    [self.view addSubview:self.dataModelTabBarContentView];
    [self.dataModelTabBarContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.equalTo(self.view);
        make.top.mas_equalTo(20);
        make.left.mas_equalTo(40);
    }];
    
    UIView *bgView = [UIView new];
    bgView.layer.cornerRadius = 5.0;
    bgView.layer.borderWidth = 2.0;
    bgView.layer.borderColor = [UIColor blueColor].CGColor;
    
    self.dataModelTabBarContentView.tabBarHeight = 50;
    self.dataModelTabBarContentView.selectedTabBarItemTitleColor = [UIColor redColor];
    self.dataModelTabBarContentView.selectedTabBarItemBackground = bgView;
    
    // 很多开发
    // 大量的使用二次封装 => 数据模型和控件进行绑定
    // 样式也可以封装
    // 导致 数据源和代理方法很歧义
    [self.dataModelTabBarContentView setDataModel:@[
                                                    @{
                                                        @"title":@"item 1",
                                                        @"view":[UIView new]
                                                        },
                                                    @{
                                                        @"title":@"item 1",
                                                        @"view":[UIView new]
                                                        },
                                                    @{
                                                        @"title":@"item 1",
                                                        @"view":[UIView new]
                                                        },
                                                    ]
     ];
    
    [self.dataModelTabBarContentView setItemDidSelectBlock:^(NSInteger index){
        NSLog(@"item %zd 被选中",index);
    }];
    
    [self.dataModelTabBarContentView reloadData];
    
    
}





@end
